package 数据结构;

public class LeetCode240_搜索二维矩阵 {
    public boolean searchMatrix(int[][] matrix, int target) {
        if(matrix.length == 0) {
            return false;
        }
        int n = 0;
        int m = matrix[0].length-1;

        while(n < matrix.length && m >= 0) {
            if(target == matrix[n][m]) {
                return true;
            }else if(target > matrix[n][m]) {
                n++;
            }else{
                m--;
            }
        }
        return false;
    }
}
